#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	string filename;
	cout << "请输入文件名";
	cin >> filename;
	ifstream file(filename,ios::in);
	if(!file)
	{
		cout << "文件打开失败" <<endl;
		exit(0);
	}
	int j=0;
	vector<string> lines;
	string line;
	while(getline(file, line))
	{
		lines.push_back(line);
	}
	file.close();
	int totalLines = lines.size();
	int startLine=max(0,totalLines-10);
	cout<<"后十行为："<<endl;
	for (int i = startLine; i < totalLines; ++i) 
	{
        cout << lines[i] << endl;
    }
    if (totalLines < 10) 
	{
        cout << "已显示整个文件" << endl;
    }
    return 0;
}
/*测试数据
C:\\Users\\醣玖\\Desktop\\第三次作业\\第三题\\cs1.txt
C:\\Users\\醣玖\\Desktop\\第三次作业\\第三题\\cs2.txt
*/